package org.jeecg.modules.monitoring.j_monitoring.service.impl;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xkcoding.http.util.StringUtil;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.util.CommonUtils;
import org.jeecg.modules.monitoring.j_monitoring.entity.RingDevices;
import org.jeecg.modules.monitoring.j_monitoring.entity.RingMonitor;
import org.jeecg.modules.monitoring.j_monitoring.entity.donghuan.devicesRequest;
import org.jeecg.modules.monitoring.j_monitoring.mapper.RingDevicesMapper;
import org.jeecg.modules.monitoring.j_monitoring.service.IRingDevicesService;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.util.ResourceUtils;

import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @Description: ring_devices
 * @Author: xiaoyq
 * @Date: 2023-07-11
 * @Version: V1.0
 */
@Service
public class RingDevicesServiceImpl extends ServiceImpl<RingDevicesMapper, RingDevices> implements IRingDevicesService {


    public String queryIdByName(String name){

        RingDevices devices = new RingDevices();
        devices.setName(name);
        QueryWrapper<RingDevices> queryWrapper = QueryGenerator.initQueryWrapper(devices, new HashMap<>());
        List<RingDevices> list = baseMapper.selectList(queryWrapper);
        if (list.size()==0){
            return "";
        }
        return list.get(0).getResourceId();
    }


    public List<RingDevices> getAllList(){
        return baseMapper.selectAllList();
    }


    public List<RingDevices> getListByNameList(List<String> nameList){
        return baseMapper.selectByNameList(nameList);

//        if (list.size()>0){
//            return list.stream().map(e->e.getResourceId()).collect(Collectors.toList());
//        }
//        return new ArrayList<>();
    }




}
